//
//  RootTabBarController.m
//  UI09_UITabBarController
//
//  Created by Scott on 16/3/21.
//  Copyright © 2016年 Scott. All rights reserved.
//

#import "RootTabBarController.h"

#import "ViewController.h"
#import "NaviOfRootFirstTabBarItem.h"
#import "VCOfSecondTabBarItem.h"
#import "VCOf3rdTabBarItem.h"
#import "VCOf4thTabBarItem.h"
#import "VCOf5thTabBarItem.h"
#import "VCOf6thTabBarItem.h"


@interface RootTabBarController ()

@end

@implementation RootTabBarController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        
        
        // 设置root的viewControllers属性.
        self.viewControllers = [self createRootOfVCs];
        
    }
    
    return self;
}



- (NSArray<UIViewController *> *)createRootOfVCs {
    
    NSMutableArray *arrOfVCs = [NSMutableArray array];
    
    // 第一个tabBarItem
    ViewController *vc = [[ViewController alloc] init];
    
    NaviOfRootFirstTabBarItem *navi = [[NaviOfRootFirstTabBarItem alloc] initWithRootViewController:vc];
    
    [arrOfVCs addObject:navi];
    [vc release];
    [navi release];
    
    // 设置item
    navi.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFeatured tag:100];
    
    
    
    navi.tabBarItem.badgeValue = @"+99";
    
    // 第二个tabBarItem
    VCOfSecondTabBarItem *item2 = [[VCOfSecondTabBarItem alloc] init];
    [arrOfVCs addObject:item2];
    [item2 release];
    
    
    item2.tabBarItem = [[[UITabBarItem alloc] initWithTitle:@"地图" image:[UIImage imageNamed:@"ditu"] tag:200] autorelease];
    
    
    // 第三个
    VCOf3rdTabBarItem *item3 = [[VCOf3rdTabBarItem alloc] init];
    [arrOfVCs addObject:item3];
    [item3 release];
    
    item3.tabBarItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemContacts tag:300] autorelease];
    
    
    // 第四个
    VCOf4thTabBarItem *item4 = [[VCOf4thTabBarItem alloc] init];
    [arrOfVCs addObject:item4];
    [item4 release];
    
    item4.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemBookmarks tag:400];
    
    
    // 第五个
    VCOf5thTabBarItem *item5 = [[VCOf5thTabBarItem alloc] init];
    
    [arrOfVCs addObject:item5];
    
    item5.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:500];
    
    
    // 第六个
    VCOf6thTabBarItem *item6 = [[VCOf6thTabBarItem alloc] init];
    
    [arrOfVCs addObject:item6];
    
    item6.tabBarItem = [[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemHistory tag:600];
    
    
    return arrOfVCs;
}




- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
